#include "StrDiff.h"

static std::string Highlighted ( char ch )
{
	return std::string ( 1, char ( 27 ) )
		 + "[41m"
		 + std::string ( 1, ch )
		 + std::string ( 1, char ( 27 ) )
		 + "[m";
}

std::string StrDiff ( std::string original, std::string comparedTo )
{
	std::string result;
	for ( int i = 0; i < int ( original.size () ); i++ )
	{
		if ( i < int ( comparedTo.size () ) && original.at ( i ) == comparedTo.at ( i ) )
			result += std::string ( 1, original.at ( i ) );
		else
			result += Highlighted ( original.at ( i ) );
	}
	return result;
}
